﻿using System;
using System.Drawing;
using System.Windows.Forms;

namespace ProxyTool.ControlAnimation
{
    public class ControlAnimatorObject : IDisposable
    {
        private const ControlAnimator.DrawMode DefaultDrawMode = ControlAnimator.DrawMode.Dots;
        private const int DefaultPenWidth = 2;
        private const int DefaultOuterCircle = 10;
        private const int DefaultInnerCircle = 3;
        private const bool DefaultClockwise = true;
        private static readonly Color DefaultBackColor = Color.Green;
        private readonly Control _control;

        public ControlAnimatorObject()
        {
            _control = null;
            ControlAnimator.FullScreenLock(DefaultDrawMode, DefaultBackColor, DefaultClockwise);
        }

        public ControlAnimatorObject(Control control)
        {
            _control = control;
            ControlAnimator.StartAnimating(control,
                DefaultDrawMode, DefaultPenWidth, DefaultOuterCircle, DefaultInnerCircle, DefaultBackColor,
                DefaultClockwise);
        }

        public void Dispose()
        {
            if (_control == null)
            {
                ControlAnimator.ReleaseFullScreenLock();
            }
            else
            {
                ControlAnimator.StopAnimating(_control);
            }
        }
    }
}